<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>搜索</title>
    <link rel="icon" href="/leek_bbs/statics/images/favicon.ico" >
    <link rel="stylesheet" href="/leek_bbs/statics/yu-ui/js_css/yu.css">
    <link rel="stylesheet" href="/leek_bbs/statics/layui/css/layui.css">
    <link rel="stylesheet" href="/leek_bbs/statics/bootstrap-3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="/leek_bbs/statics/css/main.css">
    <!-- vue-element插件样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="/leek_bbs/statics/component/common_import.js"></script>
    <!-- vue-element插件 -->
    <script src="/leek_bbs/statics/vue/element-ui/index.js"></script>
    <style>
        .row > ul > li{
            margin-left: 30px;
            padding: 18px 5px;
            width: 94%;
            border-bottom: 1px solid #e5e5e5;
        }
        .row > ul li a{
            color: #333;
        }
        .row > ul li a:hover h4{
            color: #ff6f3d;
        }
        .d-img{
            width: 25px !important;
            height: 25px !important;
            vertical-align: bottom;
        }
        .d-overflow{
            width: 80%;
            /*超过部分隐藏*/
            overflow: hidden;
            /*超过部分用...代替*/
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
        .d-overflow img{
            width: 22px;
            height: 22px;
        }
        footer{
            margin-top: 50px;
        }
        .d-hidden{
            display: none;
        }
    </style>
</head>

<body>
<div class="container-fluid">
    <!-- 导航开始 -->
    <div id="hmc">
        <head_menu_comp :is_login="isLoginShow" ref="fo"></head_menu_comp>
    </div>
    <!-- 导航结束 -->
    <!-- 中间主体部分 -->
    <div class="container " id="searchApp">
        <div class="row">
            <span style="opacity: .8;">
                <a href="/leek_bbs/skipPage/index"><span class="glyphicon glyphicon-home"></span></a>&nbsp;>&nbsp;
                <a href="javascript:;">搜索</a>
            </span>
            <!-- <span style="float: right;"><a href="javascript:;">我的收藏</a></span>-->
        </div>
        <div class="row" style="margin-top: 20px;width: 94%;background-color: #fff;" v-cloak="">
            <ul v-if="searchPosts!=null&&searchPosts!=''">
                <li v-for="item in searchPosts" >
                    <a :href="'/leek_bbs/skipPage/blogPage?theme_id='+item.id" :key="item.id">
                        <img :src="'/leek_bbs/'+item.picture" class="d-img img-circle" alt=""><span style="opacity: .7;">&emsp;{{item.post_author}}</span>
                        <h4 style="font-weight: bold;">{{item.title}}</h4>
                        <div class="d-overflow" style="opacity: .7;" v-html="item.content">
                        </div>
                    </a>
                </li>
            </ul>
            <div class="row" v-else><h3 align="center" style="margin: 30px 5px;opacity: .7;">暂无相匹配数据</h3></div>
            <!--分页开始-->
            <div class="row" style="width:100%;padding: 10px" align="center" v-if="searchPosts!=null&&searchPosts!=''" >
                <el-pagination
                        background
                        layout="prev, pager, next"
                        prev-text="上一页"
                        next-text="下一页"
                        @current-change="handleCurrentChange"
                        :current-page=currentPage
                        :page-size=pageSize
                        :total=totalCount>
                </el-pagination>
            </div>
            <!--分页结束-->
        </div>
    </div>
    <!-- 页脚部分 -->
    <footer id="footer"   ><!--class="d-hidden"-->
        <div class="row">
            <p>
                <span>Copyright &nbsp;© 2020 &nbsp;凛冬</span>
                <span>版权所有&nbsp;All Rights Reserved.</span>
            </p>
        </div>
    </footer>
</div>
<script src="/leek_bbs/statics/component/head_menu.js"></script>
<script>
    const searchApp = new Vue({
        el:"#searchApp",
        data:{
            isExistData:false,
            carePosts:[],
            pageSize:5,			//每页显示多少条数据
            currentPage:1,		//当前页
            totalCount:0,		//总数据条数
            searchPosts:[],   //搜索数据
        },
        methods:{
            getSearchPostsData(){
                let  keyParams = getUrlParam('searchParam');
                if(keyParams!=''&&keyParams!=null){
                    axios.post("/leek_bbs/bbs/postBrowse/getSearchPosts",{
                        keyParams:keyParams,
                        // 每页显示的条数
                        pageSize:this.pageSize,
                        // 显示第几页
                        currentPage:this.currentPage,
                    }).then((response)=>{
                        const data = response.data;
                        this.searchPosts = data.searchPosts;
                        console.log(this.searchPosts)
                        console.log(data);
                        this.totalCount=data.totalCount;
                    }).catch(error => {
                        ui.error("获取数据出现异常",3000,true);
                        console.log(error);
                    })
                }else{
                    ui.alert("请输入搜索关键字",1500,true);
                }
            },
            // 显示第几页
            handleCurrentChange(val) {
                this.currentPage =val;
                this.getSearchPostsData();
            }
        },
        created(){
            this.getSearchPostsData();
        }
    });
    /*setTimeout(() => {
        if (userInfo != null){
            dynamicApp.getSearchPostsData();
            $("#dynamicApp").removeClass("d-hidden");
            $("#footer").removeClass("d-hidden");
        } else {
            layui.login();
        }
    },200);*/

</script>
</body>
</html>